#!/usr/bin/env python3
# -*- coding=utf-8 -*-
# 本脚由亁颐堂现任明教教主编写，用于乾颐盾Python课程！
# 教主QQ:605658506
# 亁颐堂官网www.qytang.com
# 教主技术进化论拓展你的技术新边疆
# https://ke.qq.com/course/271956?tuin=24199d8a

import netifaces
import platform
import pprint
pp = pprint.PrettyPrinter(indent=4)


def get_mac_address(ifname):
    if platform.system() == "Linux":
        # pp.pprint(netifaces.ifaddresses(ifname))
        # print(netifaces.AF_LINK)
        return netifaces.ifaddresses(ifname)[netifaces.AF_LINK][0]['addr']
    elif platform.system() == "Windows":
        from Part1_Classic_Protocols.Tools.WIN_IFNAME import win_from_name_get_id
        if_id = win_from_name_get_id(ifname)
        return netifaces.ifaddresses(if_id)[netifaces.AF_LINK][0]['addr']
    else:
        print('操作系统不支持,本脚本只能工作在Windows或者Linux环境!')


if __name__ == '__main__':
    # print(get_mac_address("Net1"))
    print(get_mac_address("ens33"))